package frontend.Combine;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableCellRenderer;

public class BasicCellRender extends DefaultTableCellRenderer {
	public Color defaultColor = Color.white;

	private final Color backGroundColor = UIManager
			.getColor("Table.background");
	private final Color foreGroundColor = UIManager
			.getColor("Table.foreground");
	private final Color selectedBackground = UIManager
			.getColor("Table.selectionBackground");
	private final Color selectedForeground = UIManager
			.getColor("Table.selectionForeground");

	@Override
	    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
	        Component com = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
	      
	        if(row % 2 == 0) {
	        	if(isSelected) {
	        		com.setBackground(selectedBackground);
	        		com.setForeground(selectedForeground);
	        	} else {
	        		com.setBackground(Color.LIGHT_GRAY);
	        		com.setForeground(foreGroundColor);
	        	}
	        } else {
	        	if(isSelected) {
	        		com.setBackground(selectedBackground);
	        		com.setForeground(selectedForeground);
	        	} else {
	        		com.setBackground(backGroundColor);
	        		com.setForeground(foreGroundColor);
	        	}
	        }
	        return com;
	    }
}
